package com.jinzhi.jzweb.controller;


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import cn.hutool.core.util.NumberUtil;
import com.jinzhi.common.utils.StringUtil;
import com.jinzhi.jzapi.examination.pojo.ExaminationsVo;
import com.jinzhi.jzweb.domain.*;
import com.jinzhi.jzweb.pojo.*;
import com.jinzhi.jzweb.pojo.MarkStatisticsExcel;
import com.jinzhi.jzweb.pojo.ModuleConfig.JzJinzhuanDispositionTopic;
import com.jinzhi.jzweb.pojo.ModuleConfig.StatisticsVO;
import com.jinzhi.jzweb.service.*;
import com.jinzhi.jzweb.service.moduleConfig.IJzJinzhuanDispositionTopicService;
import com.jinzhi.jzweb.utils.EasyPoiUtil;
import com.jinzhi.jzweb.utils.ZipFileUtils;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;

import javax.servlet.http.HttpServletResponse;

/**
 * 
 * <pre>
 * 打分表
 * </pre>
 * <small> 2023-06-19 08:45:15 | lance</small>
 */
@RestController
@RequestMapping("/jzweb/mark")
@Api(value = "打分", tags = "打分")
public class MarkController extends BaseController {
	@Autowired
	private MarkService markService;

	@Autowired
	private ExaminationBatchService examinationBatchService;

	@Autowired
	private ExaminationResultsService examinationResultsService;

	@Autowired
	private ExaminationBatchComSService examinationBatchComSService;

	@Autowired
	private ExaminationBatchComService examinationBatchComService;


	@Autowired
	private IJzJinzhuanDispositionTopicService dispositionTopicService;

	@Autowired
	private StuSignUpComService stuSignUpService;

	@Autowired
	private ExaminationAnswerSheetComService examinationAnswerSheetComService;




	/**
	 * 查询实操考试批次（列表数据）
	 * @return
	 */
	@ResponseBody
	@PostMapping("/selEbatchId")
	public Result<List<ExaminationBatchDO>> selEbatchId(@RequestBody ExaminationBatchDO  examinationBatchDO) {//Long competitionType
		EntityWrapper wrapper =new EntityWrapper();
		if (Objects.nonNull(examinationBatchDO.getCompetitionType()) && !examinationBatchDO.getCompetitionType().equals(null) && !examinationBatchDO.getCompetitionType().equals("null") && !examinationBatchDO.getCompetitionType().equals("")){
			wrapper.addFilter("{0} like CONCAT('%',competition_type,'%')",examinationBatchDO.getCompetitionType());
		}
//		wrapper.eq("competition_type", 1);
		wrapper.eq("type",4);
		wrapper.orderBy("id",true);
		if (!StringUtils.isBlank(this.getUser().getTrack()) ){
				if(this.getUser().getTrack().equals("B") ||   this.getUser().getTrack().equals("C")){
					//等于A就理论打分的裁判
					wrapper.like("referee_id",this.getUserId().toString());
				}
		}
		if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("E")){
			//竞赛一级管理员
			wrapper.eq("create_id",this.getUserId());//创建人id
		}else if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("D")){
			//工作人员
			wrapper.like("encipher",this.getUserId().toString());//创建人id（工作人员id）
		}
		List<ExaminationBatchDO> examinationBatchDOList = examinationBatchService.selectList(wrapper);
		for (int i = 0;i < examinationBatchDOList.size();i++){
			EntityWrapper ebatchWrapper =new EntityWrapper();
			ebatchWrapper.eq("pid",examinationBatchDOList.get(i).getId());
			ebatchWrapper.eq("cbatch_id",examinationBatchDOList.get(i).getCbatchId());
			ebatchWrapper.orderBy("id",true);
			List<ExaminationBatchComSDO> ebatchlist = examinationBatchComSService.selectList(ebatchWrapper);
			examinationBatchDOList.get(i).setEbatchlist(ebatchlist);
		}
		return Result.ok(examinationBatchDOList);
	}


	/**
	 * 查询实操考试批次（列表数据），选手管理实操页面使用
	 * @return
	 */
	@ResponseBody
	@PostMapping("/selEbatchIds")
	public Result<List<ExaminationBatchDO>> selEbatchIds(@RequestBody ExaminationBatchDO  examinationBatchDO) {//Long competitionType
		EntityWrapper wrapper =new EntityWrapper();
		if (Objects.nonNull(examinationBatchDO.getCompetitionType()) && !examinationBatchDO.getCompetitionType().equals(null) && !examinationBatchDO.getCompetitionType().equals("null") && !examinationBatchDO.getCompetitionType().equals("")){
			wrapper.addFilter("{0} like CONCAT('%',competition_type,'%')",examinationBatchDO.getCompetitionType());
		}
//		wrapper.eq("competition_type", 1);
		wrapper.eq("type",3);
		wrapper.orderBy("id",true);
		if (!StringUtils.isBlank(this.getUser().getTrack()) ){
			if(this.getUser().getTrack().equals("B") ||   this.getUser().getTrack().equals("C")){
				//等于A就理论打分的裁判
				wrapper.like("referee_id",this.getUserId().toString());
			}
		}
		if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("E")){
			//竞赛一级管理员
			wrapper.eq("create_id",this.getUserId());//创建人id
		}else if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("D")){
			//工作人员
			wrapper.like("encipher",this.getUserId().toString());//创建人id（工作人员id）
		}
		List<ExaminationBatchDO> examinationBatchDOList = examinationBatchService.selectList(wrapper);
		for (int i = 0;i < examinationBatchDOList.size();i++){
			EntityWrapper ebatchWrapper =new EntityWrapper();
			ebatchWrapper.eq("pid",examinationBatchDOList.get(i).getId());
			ebatchWrapper.eq("cbatch_id",examinationBatchDOList.get(i).getCbatchId());
			ebatchWrapper.orderBy("id",true);
			List<ExaminationBatchComSDO> ebatchlist = examinationBatchComSService.selectList(ebatchWrapper);
			examinationBatchDOList.get(i).setEbatchlist(ebatchlist);
		}
		return Result.ok(examinationBatchDOList);
	}


	/**
	 * 查询理论考试批次（列表是数据）
	 * @return
	 */
	@ResponseBody
	@PostMapping("/selEbatchIdLiLuen")
	public Result<List<ExaminationBatchDO>> selEbatchIdLiLuen(@RequestBody ExaminationBatchDO  examinationBatchDO) {//Long competitionType
		EntityWrapper wrapper =new EntityWrapper();
		if (Objects.nonNull(examinationBatchDO.getCompetitionType()) && !examinationBatchDO.getCompetitionType().equals(null) && !examinationBatchDO.getCompetitionType().equals("null") && !examinationBatchDO.getCompetitionType().equals("")){
			wrapper.eq("competition_type", examinationBatchDO.getCompetitionType());
		}
		wrapper.eq("type",3); //查询理论批次
		if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("A")){
				//等于A就理论打分的裁判
			wrapper.like("refereeA",this.getUserId().toString());
		}

		if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("E")){
				//竞赛一级管理员
			wrapper.eq("create_id",this.getUserId());//创建人id
		}else if (!StringUtils.isBlank(this.getUser().getTrack()) && this.getUser().getTrack().equals("D")){
			//工作人员
			wrapper.like("encipher",this.getUserId().toString());//创建人id（工作人员id）
		}

		wrapper.orderBy("id",true);
		List<ExaminationBatchDO> examinationBatchDOList = examinationBatchService.selectList(wrapper);
		return Result.ok(examinationBatchDOList);
	}



//	/**
//	 * 分数统计导出
//	 * competition ABC赛场
//	 * ebatchId 考试批次
//	 * cbatchId 认证批次
//	 * @return
//	 */
//	@ResponseBody
//	@GetMapping("/scoreStatisticsexcel")
//	public void scoreStatisticsexcel(String competition, String ebatchId, String cbatchId, HttpServletResponse response){
//		Map map =new HashMap();
//		map.put("competition",competition); //根据赛场查询 abc必填
//		if (StringUtil.notEmpty(ebatchId)) { //如果考试批次不为空
//			map.put("ebatchId", ebatchId);
//		}
//		// 查询列表数据
//		List<MarkDO> list = markService.selectListMarkDO(map);
//		List<MarkExcel> markExcels =new ArrayList<>();
//		for (int i=0;i<list.size();i++){
//			ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(list.get(i).getRaceId());
//			list.get(i).setRaceName(examinationBatchComSDO.getName());
//			if (list.get(i).getRealityUm2() == null){
//				list.get(i).setRealityUm2("未参加考试");
//			}
//			MarkExcel markExcel =new MarkExcel();
//			markExcel.setNum2(list.get(i).getRaceName() + "-" + list.get(i).getRealityUm2()); //理论二次加密
//			markExcel.setUnitName(list.get(i).getOrgName()); //单位名称
//			markExcel.setName(list.get(i).getSignName()); //考生姓名
//			markExcel.setIdNumber(list.get(i).getIdentity()); //身份证
//
//			Map selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",list.get(i).getEbatchId()); //考试批次
//			selRefereeIdMap.put("competition",list.get(i).getCompetition()); //abc赛场
//			selRefereeIdMap.put("stuId",list.get(i).getSignId());//考生id
//
//			List<String> refereeId = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSun = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			Double totalScore = Double.valueOf(scoreSun);
//			totalScore =  (totalScore/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			totalScore = new BigDecimal(totalScore).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//
//			List<String> scoreABC = markService.selScoreABC(selRefereeIdMap); //查询出分数
////			if (scoreABC == null){
////				markExcel.setScores1("0.0");
////				markExcel.setScores2("0.0");
////				markExcel.setScores3("0.0");
////			}
////			if (scoreABC.size() == 3){
////				markExcel.setScores1(scoreABC.get(0));
////				markExcel.setScores2(scoreABC.get(1));
////				markExcel.setScores3(scoreABC.get(2));
////			}
////			if (scoreABC.size() == 2){
////				markExcel.setScores1(scoreABC.get(0));
////				markExcel.setScores2(scoreABC.get(1));
////				markExcel.setScores3("0.0");
////			}
////			if (scoreABC.size() == 1){
////				markExcel.setScores1(scoreABC.get(0));
////				markExcel.setScores2("0.0");
////				markExcel.setScores3("0.0");
////			}
//			markExcel.setScore(Double.valueOf(totalScore));
//			markExcels.add(markExcel);
//		}
//		//导出操作
//		EasyPoiUtil.exportExcel(markExcels, competition +"赛场成绩导出", competition + "赛场成绩导出", MarkExcel.class, competition + "赛场成绩导出", response);
//	}



	/** 赛场统计数据导出操作 */
	@ResponseBody
	@GetMapping("/scorePracticalStatisticsexcel")
	public Result  scorePracticalStatisticsexcel(String cbatchId,String ebatchId,String competition,String competitionName,String competitionId,HttpServletResponse response)  {
		ArrayList<Long>	ids	=	new ArrayList<>();
		ArrayList<Long>	stuIds	=	new ArrayList<>();
		//导出的数据
		List<ScoreStatisticsexcel> excel = new ArrayList<>();
		List<Map<Object,Object>> excelList = new ArrayList<>();
		List<ScoreOneStatisticsexcel> excelOne = new ArrayList<>();
		List<ScoreTwoStatisticsexcel> excelTwo = new ArrayList<>();
		List<ScoreThreeStatisticsexcel> excelThree = new ArrayList<>();
		List<ScoreFourStatisticsexcel> excelFour = new ArrayList<>();
		List<ScoreFiveStatisticsexcel> excelFive = new ArrayList<>();
		//查询出实操赛场学员信息
		//查询模板任务
		//如果批次下面没有赛场
		ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(competitionId);
		if (examinationBatchComSDO == null){
//			Page<StuSignUpComDO> stuList = new Page<>();
//			statisticsVO.setStuSignUpComDO(stuList);
			EasyPoiUtil.exportExcel(excel, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			return Result.fail("没有可导出的数据");
		}

		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type",competition);//赛场（B）			//模板id
		wrapperTopic.eq("module_id",examinationBatchComSDO.getModileId());
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		if (topicList.size() <= 0){
			EasyPoiUtil.exportExcel(excel, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			return Result.fail("没有可导出的数据");
		}
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains(competitionName)){//如果相等就是安全防护任务
				//模板id
				ids.add(topicList.get(i).getId());
			}
		}
		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
		stuSignUpComDO.setEbatchId(Long.valueOf(ebatchId));
		stuSignUpComDO.setCbatchId(Long.valueOf(cbatchId));
		stuSignUpComDO.setCompetition(competition);
		stuSignUpComDO.setJinzhuanTopicId(String.valueOf(ids.get(0)));
		stuSignUpComDO.setCompetitionId(competitionId);//赛场id
		stuSignUpComDO.setRaceId(examinationBatchComSDO.getId());
		List<StuSignUpComDO> stuList = stuSignUpService.ListUstASCExcel(stuSignUpComDO);
		if (stuList.size() <= 0){
			EasyPoiUtil.exportExcel(excel, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			return Result.ok("没有可导出的数据");
		}
		for (int i = 0 ;i < stuList.size(); i++){
			//考生id
			stuIds.add(stuList.get(i).getId());
		}
		//查询出打分信息
		Map map =new HashMap();
		map.put("competition",competition);
		map.put("signId",stuIds);
		map.put("jinzhuanTopicId",ids);
		map.put("cbatchId",Long.valueOf(cbatchId));
		map.put("ebatchId",Long.valueOf(ebatchId));
		map.put("race_id",examinationBatchComSDO.getId());
		//查询出裁判数量
		List<MarkVO> mrkRefereeVOS = markService.selectRefereeBCSize(map);
		//裁判打分数据
		List<MarkVO> markVOS = markService.seleScoreTopicContent(map);
		for (int i = 0;i<stuList.size();i++){
			ArrayList<MarkVO>	MarkVOlist	=	new ArrayList<>();
			Map<Object, Object> ExcelMap = new HashMap<>();
//			ScoreStatisticsexcel scoreStatisticsexcel = new ScoreStatisticsexcel();
			//进行学员匹配
			ScoreOneStatisticsexcel scoreOneStatisticsexcel = new ScoreOneStatisticsexcel();
			ScoreTwoStatisticsexcel scoreTwoStatisticsexcel = new ScoreTwoStatisticsexcel();
			ScoreThreeStatisticsexcel scoreThreeStatisticsexcel = new ScoreThreeStatisticsexcel();
			ScoreFourStatisticsexcel scoreFourStatisticsexcel = new ScoreFourStatisticsexcel();
			ScoreFiveStatisticsexcel scoreFiveStatisticsexcel = new ScoreFiveStatisticsexcel();
			int s = 0;
			for (int k = 0;k<markVOS.size();k++){//这里长度多少就有几个裁判
				if (stuList.get(i).getId().equals(markVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = markVOS.get(k).getRefereeScore().split("/");//分割出来
					BigDecimal refereeScore = new BigDecimal(0);
					for (String score : refereeScores) {
						refereeScore = new BigDecimal(score).add(refereeScore);//得到所有裁判打的总分
					}
					markVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					MarkVOlist.add(markVOS.get(k));
					s = s + 1;
					ExcelMap.put("裁判"+ s ,markVOS.get(k).getRefereeScore());
				}
			}
			//将两个集合合并
			List<MarkVO> resultList = Stream.concat(MarkVOlist.stream(), mrkRefereeVOS.stream())
					.collect(Collectors.toList());
			//去掉重复的裁判数据
			List<MarkVO> resultListDuplicate = resultList.stream().filter(distinctByKey(b->b.getRefereeId())).collect(Collectors.toList());
			stuList.get(i).setMarkVO(resultListDuplicate);
			stuList.get(i).getMarkVO().size();//有多少条数就有多少个裁判
			Double TotalScore = 0.0;
			for (int j = 0; j< stuList.get(i).getMarkVO().size();j++){//这个学员的所有裁判打的安全防护分
				if (!stuList.get(i).getMarkVO().get(j).getRefereeScore().equals("-")){
					TotalScore = Double.valueOf(stuList.get(i).getMarkVO().get(j).getRefereeScore())  +TotalScore;//得到所有裁判打的总分
				}
			}

			//最终学员这个任务所获得的总分
			stuList.get(i).setTotalScore(new BigDecimal(TotalScore /stuList.get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());//最终得分为每个裁判打的总分除以裁判人数
			ExcelMap.put("赛场得分",stuList.get(i).getTotalScore());
			//设置五个导出类
			//循环
			//一个裁判
			if (stuList.get(i).getMarkVO().size() == 1){
				for (int p = 0;p < stuList.get(i).getMarkVO().size();p++){
					if (p == 0){
						scoreOneStatisticsexcel.setRefeereOneScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					}
					//将考生信息存入导出类中
					ExcelMap.put("一次加密序号",stuList.get(i).getComNums());
					scoreOneStatisticsexcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
					ExcelMap.put("二次加密序号",stuList.get(i).getComNums());
					scoreOneStatisticsexcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
					ExcelMap.put("参赛单位",stuList.get(i).getUnitName());
					scoreOneStatisticsexcel.setUnitName(stuList.get(i).getUnitName());
					ExcelMap.put("姓名",stuList.get(i).getName());
					scoreOneStatisticsexcel.setName(stuList.get(i).getName());
					ExcelMap.put("身份证号码",stuList.get(i).getIdNumber());
					scoreOneStatisticsexcel.setIdNumber(stuList.get(i).getIdNumber());
					scoreOneStatisticsexcel.setTotalScore(stuList.get(i).getTotalScore());
				}
					String[] arr = stuList.get(i).getRefereeremark().split("/");
					Set<String> set = new HashSet<String>(Arrays.asList(arr));
					String result = String.join("/", set);
					scoreOneStatisticsexcel.setRefereeRemark(result);
			}
				//两个裁判
			   if (stuList.get(i).getMarkVO().size() == 2){
					for (int p = 0;p < stuList.get(i).getMarkVO().size();p++){
						if (p == 0){
							scoreTwoStatisticsexcel.setRefeereOneScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
						}else if (p == 1){
							scoreTwoStatisticsexcel.setRefeereTwoScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
						}
						//将考生信息存入导出类中
						ExcelMap.put("一次加密序号",stuList.get(i).getComNums());
						scoreTwoStatisticsexcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
						ExcelMap.put("二次加密序号",stuList.get(i).getComNums());
						scoreTwoStatisticsexcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
						ExcelMap.put("参赛单位",stuList.get(i).getUnitName());
						scoreTwoStatisticsexcel.setUnitName(stuList.get(i).getUnitName());
						ExcelMap.put("姓名",stuList.get(i).getName());
						scoreTwoStatisticsexcel.setName(stuList.get(i).getName());
						ExcelMap.put("身份证号码",stuList.get(i).getIdNumber());
						scoreTwoStatisticsexcel.setIdNumber(stuList.get(i).getIdNumber());
						scoreTwoStatisticsexcel.setTotalScore(stuList.get(i).getTotalScore());
					}
					   String[] arr = stuList.get(i).getRefereeremark().split("/");
					   Set<String> set = new HashSet<String>(Arrays.asList(arr));
					   String result = String.join("/", set);
					   scoreTwoStatisticsexcel.setRefereeRemark(result);
				}
				//三个裁判
			   if (stuList.get(i).getMarkVO().size() == 3){
				  for (int p = 0;p < stuList.get(i).getMarkVO().size();p++){
					 if (p == 0){
						scoreThreeStatisticsexcel.setRefeereOneScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 1){
						scoreThreeStatisticsexcel.setRefeereTwoScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 2){
						scoreThreeStatisticsexcel.setRefeereThreeScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }
				  }
				   scoreThreeStatisticsexcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
				   scoreThreeStatisticsexcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
				   scoreThreeStatisticsexcel.setUnitName(stuList.get(i).getUnitName());
				   scoreThreeStatisticsexcel.setName(stuList.get(i).getName());
				   scoreThreeStatisticsexcel.setIdNumber(stuList.get(i).getIdNumber());
				   scoreThreeStatisticsexcel.setTotalScore(stuList.get(i).getTotalScore());
				   String[] arr = stuList.get(i).getRefereeremark().split("/");
				   Set<String> set = new HashSet<String>(Arrays.asList(arr));
				   String result = String.join("/", set);
				   scoreThreeStatisticsexcel.setRefereeRemark(result);
			   }
			   //四个裁判
			   if (stuList.get(i).getMarkVO().size() == 4){
				  for (int p = 0;p < stuList.get(i).getMarkVO().size();p++){
					 if (p == 0){
						scoreFourStatisticsexcel.setRefeereOneScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 1){
						scoreFourStatisticsexcel.setRefeereTwoScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 2){
						scoreFourStatisticsexcel.setRefeereThreeScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 3){
						scoreFourStatisticsexcel.setRefeereFourScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }
				  }
				   scoreFourStatisticsexcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
				   scoreFourStatisticsexcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
				   scoreFourStatisticsexcel.setUnitName(stuList.get(i).getUnitName());
				   scoreFourStatisticsexcel.setName(stuList.get(i).getName());
				   scoreFourStatisticsexcel.setIdNumber(stuList.get(i).getIdNumber());
				   scoreFourStatisticsexcel.setTotalScore(stuList.get(i).getTotalScore());
				   String[] arr = stuList.get(i).getRefereeremark().split("/");
				   Set<String> set = new HashSet<String>(Arrays.asList(arr));
				   String result = String.join("/", set);
				   scoreFourStatisticsexcel.setRefereeRemark(result);
			   }
		   //五个裁判
		   if (stuList.get(i).getMarkVO().size() == 5){
				  for (int p = 0;p < stuList.get(i).getMarkVO().size();p++){
					 if (p == 0){
						scoreFiveStatisticsexcel.setRefeereOneScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 1){
						scoreFiveStatisticsexcel.setRefeereTwoScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 2){
						 scoreFiveStatisticsexcel.setRefeereThreeScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if (p == 3){
						 scoreFiveStatisticsexcel.setRefeereFourScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }else if(p == 4){
						 scoreFiveStatisticsexcel.setRefeereFiveScore(stuList.get(i).getMarkVO().get(p).getRefereeScore());
					 }
				  }
				   scoreFiveStatisticsexcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
				   scoreFiveStatisticsexcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
				   scoreFiveStatisticsexcel.setUnitName(stuList.get(i).getUnitName());
				   scoreFiveStatisticsexcel.setName(stuList.get(i).getName());
				   scoreFiveStatisticsexcel.setIdNumber(stuList.get(i).getIdNumber());
				   scoreFiveStatisticsexcel.setTotalScore(stuList.get(i).getTotalScore());
				   String[] arr = stuList.get(i).getRefereeremark().split("/");
				   Set<String> set = new HashSet<String>(Arrays.asList(arr));
				   String result = String.join("/", set);
				   scoreFiveStatisticsexcel.setRefereeRemark(result);
			  }
			excelList.add(ExcelMap);
			excelOne.add(scoreOneStatisticsexcel);
			excelTwo.add(scoreTwoStatisticsexcel);
			excelThree.add(scoreThreeStatisticsexcel);
			excelFour.add(scoreFourStatisticsexcel);
			excelFive.add(scoreFiveStatisticsexcel);
		}
		for (int i = 0;i<stuList.size();i++){
			if (stuList.get(i).getMarkVO().size() == 1){
				EasyPoiUtil.exportExcel(excelOne, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreOneStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			}else if (stuList.get(i).getMarkVO().size() == 2){
				EasyPoiUtil.exportExcel(excelTwo, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreTwoStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			}else if (stuList.get(i).getMarkVO().size() == 3){
				EasyPoiUtil.exportExcel(excelThree, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreThreeStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			}else if (stuList.get(i).getMarkVO().size() == 4){
				EasyPoiUtil.exportExcel(excelFour, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreFourStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			}else if (stuList.get(i).getMarkVO().size() == 5){
				EasyPoiUtil.exportExcel(excelFive, competitionName+"赛场成绩导出",  competitionName+"赛场成绩导出", ScoreFiveStatisticsexcel.class, competitionName+"赛场成绩导出", response);
			}
		}
		return Result.ok("导出成功！请勿关闭浏览器,五分钟后浏览！");
	}


	/** 成绩总统计导出 */
	@ResponseBody
	@GetMapping("/personageStatisticsexcel")
	public  Result  personageStatisticsexcel(Long cbatchId,HttpServletResponse response){
		List<MarkStatisticsExcel> list = stuSignUpService.personageStatisticsexcel(cbatchId, response);
		EasyPoiUtil.exportExcel(list, "成绩总统计导出",  "成绩总统计导出", MarkStatisticsExcel.class, "成绩总统计导出", response);

		return Result.ok("导出成功!");
	}
	/** 裁判打分处理  */
	private void  dateHandleExcel (List<StuSignUpComDO> stuList,List<MarkVO> secureMarkVOS,String competition) {
		for (int i = 0; i < stuList.size(); i++) {
			ArrayList<MarkVO> MarkVO = new ArrayList<>();
			for (int k = 0; k < secureMarkVOS.size(); k++) {
				if (stuList.get(i).getId().equals(secureMarkVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = secureMarkVOS.get(k).getRefereeScore().split("/");//分割出来
					BigDecimal refereeScore = new BigDecimal(0);
					for (String score : refereeScores) {
						refereeScore = new BigDecimal(score).add(refereeScore);//得到所有裁判打的总分
					}
					secureMarkVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中（这里就是这个裁判打的这个任务的总分）
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象：" + secureMarkVOS.get(k));
					MarkVO.add(secureMarkVOS.get(k));
				}
			}
			stuList.get(i).setMarkVO(MarkVO);
			stuList.get(i).getMarkVO().size();//有多少条数就有多少个裁判
			Double TotalScore = 0.0;
			for (int j = 0; j < stuList.get(i).getMarkVO().size(); j++) {//这个学员的所有裁判打的安全防护分
				TotalScore = Double.parseDouble(stuList.get(i).getMarkVO().get(j).getRefereeScore()) + TotalScore;//得到所有裁判打的总分（这里因为是个人总统计，所以这里是B赛场这个任务所得的总分）
			}
			//这里传入对应的参数，判断是那个赛场的得分
			if (competition.equals("安全防护")){//获得该学员安全防护的得分
				//最终学员这个任务所获得的总分（这里是B赛场安全防护得分），因为是要最终这个学员三个赛场的总得分所以要加上另外两个赛场的得分
				//最终学员这个任务所获得的总分
				if (TotalScore <= 0){
					stuList.get(i).setSecureScore(0.0);
				}else {
					BigDecimal bg = new BigDecimal(TotalScore / stuList.get(i).getMarkVO().size());
					stuList.get(i).setSecureScore( bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());//最终得分为每个裁判打的总分除以裁判人数
				}
			}else if(competition.equals("日常保健")){//获得该学员的日常保健的得分
				if (TotalScore <= 0){
					stuList.get(i).setHealthScore(0.0);
				}else {
					stuList.get(i).setHealthScore(new BigDecimal(TotalScore / stuList.get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}
			}else if (competition.equals("生活照料")){
				if (TotalScore <= 0){
					stuList.get(i).setLookAfterScore(0.0);
				}else {
					stuList.get(i).setLookAfterScore(new BigDecimal(TotalScore / stuList.get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}
			}else if (competition.equals("早期发展指导")){
				if (TotalScore <= 0){
					stuList.get(i).setDevelopmentGuidanceScore(0.0);
				}else {
					stuList.get(i).setDevelopmentGuidanceScore(new BigDecimal(TotalScore / stuList.get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}
			}

		}
	}


	//数据流去重
	public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
		Map<Object,Boolean> seen = new ConcurrentHashMap<>();
		return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
	}




	/**
	 *安全防护赛场成绩统计（BC赛场下的所有安全返回的赛场成绩统计）
	 * */
	@ApiOperation(value = "安全防护赛场成绩统计", notes = "安全防护赛场成绩统计")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/secureList")
	@ResponseBody
	public Result<?>  secureList(@RequestBody ExaminationsVo examinationsVo){
		StatisticsVO statisticsVO = new StatisticsVO();
		ArrayList<Long>	ids	=	new ArrayList<>();
		ArrayList<Long>	stuIds	=	new ArrayList<>();
		//查询出实操赛场学员信息
		//查询这个赛场下的模板任务
		  //赛场数据
			//如果批次下面没有赛场
		ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(examinationsVo.getCompetitionId());
		if (examinationBatchComSDO == null){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			 return Result.ok(statisticsVO);
		}
		 //查询对应的模板数据
		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type","B");//赛场（B）			//模板id
		wrapperTopic.eq("module_id",examinationBatchComSDO.getModileId());
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		if (topicList.size() <= 0){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains("安全防护")){//如果相等就是安全防护任务
				//模板id
				 ids.add(topicList.get(i).getId());
			}
		}
		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
		stuSignUpComDO.setEbatchId(examinationsVo.getEbatchId());
		stuSignUpComDO.setCbatchId(examinationsVo.getCbatchId());
		stuSignUpComDO.setCompetition("B");
		stuSignUpComDO.setJinzhuanTopicId(String.valueOf(ids.get(0)));
		stuSignUpComDO.setCompetitionId(examinationsVo.getCompetitionId());//赛场id
		stuSignUpComDO.setRaceId(examinationBatchComSDO.getId());
		Page<StuSignUpComDO> stuList = stuSignUpService.ListUstASC(examinationsVo.getCurrent(), examinationsVo.getNumber(), stuSignUpComDO);
		List<StuSignUpComDO> ss = stuList.getRecords().stream().filter(a -> Objects.nonNull(a.getId())).collect(Collectors.toList());
		stuList.setRecords(ss);
		if (stuList.getRecords().size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0 ;i < stuList.getRecords().size(); i++){
			//考生id
			stuIds.add(stuList.getRecords().get(i).getId());
		}
		//查询出打分信息
		Map map =new HashMap();
		map.put("competition","B");
		map.put("signId",stuIds);
		map.put("jinzhuanTopicId",ids);
		map.put("cbatchId",examinationsVo.getCbatchId());
		map.put("ebatchId",examinationsVo.getEbatchId());
		map.put("race_id",examinationBatchComSDO.getId());
		//查询出裁判数量
		List<MarkVO> mrkRefereeVOS = markService.selectRefereeBCSize(map);
		//裁判打分数据
		List<MarkVO> markVOS = markService.seleScoreTopicContent(map);
		if (markVOS.size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//进行学员匹配
		for (int i = 0;i<stuList.getRecords().size();i++){
			ArrayList<MarkVO>	MarkVOlist	=	new ArrayList<>();
			for (int k = 0;k<markVOS.size();k++){
				if (stuList.getRecords().get(i).getId().equals(markVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = markVOS.get(k).getRefereeScore().split("/");//分割出来
					Double refereeScore = 0.0;
					for (String score : refereeScores) {
						refereeScore = Double.valueOf(score) + refereeScore;//两个人分数相加（计算）
					}
					markVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象："+markVOS.get(k));
					MarkVOlist.add(markVOS.get(k));
					//将批次和学员id返回到学生信息中
					stuList.getRecords().get(i).setCbatchId(markVOS.get(k).getCbatchId());
					stuList.getRecords().get(i).setSignId(markVOS.get(k).getSignId());
				}
			}
				//将两个集合合并
				List<MarkVO> resultList = Stream.concat(MarkVOlist.stream(), mrkRefereeVOS.stream())
						.collect(Collectors.toList());
				//去掉重复的裁判数据
				List<MarkVO> resultListDuplicate = resultList.stream().filter(distinctByKey(b->b.getRefereeId())).collect(Collectors.toList());
				if(resultList.size() > 0){
					stuList.getRecords().get(i).setMarkVO(resultListDuplicate);
					stuList.getRecords().get(i).getMarkVO().size();//有多少条数就有多少个裁判
					BigDecimal TotalScore = new BigDecimal(0);
					for (int j = 0; j< stuList.getRecords().get(i).getMarkVO().size();j++){//这个学员的所有裁判打的安全防护分
						if (!stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore().equals("-")){
							TotalScore = new BigDecimal(stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore()).add(TotalScore);//得到所有裁判打的总分add是相加
						}
					}
					if (TotalScore.compareTo(BigDecimal.ZERO)!=0){
						BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
						BigDecimal totalScore = TotalScore.divide(size,2,BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);//divide是除以
						//最终学员这个任务所获得的总分
						stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
					}else if (TotalScore.compareTo(BigDecimal.ZERO)==0){
						BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
						BigDecimal totalScore = TotalScore.divide(size);
						stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
					}
				}
		}
		//根据总分进行排序
		Collections.sort(stuList.getRecords(),Comparator.comparing(StuSignUpComDO::getTotalScore).reversed());
		//赛场人数
		statisticsVO.setStuNumber(stuList.getRecords().size());
		//最高分
		Double maxScore = 0.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
					if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() > maxScore){
						maxScore = stuList.getRecords().get(i).getTotalScore();
					}
		}
		statisticsVO.setMaxScore(maxScore);
		//最低分
		Double minScore = 100.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() < minScore){
				minScore = stuList.getRecords().get(i).getTotalScore();
			}else if (minScore == 0.0){
				minScore = 0.0;
			}
		}
		statisticsVO.setMinScore(minScore);
		//将用户分数对象存入最终对象里面去
		statisticsVO.setStuSignUpComDO(stuList);
//		statisticsVO.getStuSignUpComDO().getSize();
//		statisticsVO.getStuSignUpComDO().getTotal();
		statisticsVO.setSize(statisticsVO.getStuSignUpComDO().getSize());
		statisticsVO.setTotal(statisticsVO.getStuSignUpComDO().getTotal());
		return Result.ok(statisticsVO);
	}


	/**
	 *日常保健赛场成绩统计
	 * */
	@ApiOperation(value = "日常保健赛场成绩统计", notes = "日常保健赛场成绩统计")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/healthList")
	@ResponseBody
	public Result<?>  healthList(@RequestBody ExaminationsVo examinationsVo){
		StatisticsVO statisticsVO = new StatisticsVO();
		ArrayList<Long>	ids	=	new ArrayList<>();
		ArrayList<Long>	stuIds	=	new ArrayList<>();
		//查询出实操赛场学员信息
		//赛场数据
		ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(examinationsVo.getCompetitionId());
		if (examinationBatchComSDO == null){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//查询模板任务
		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type","B");//赛场（B）
		wrapperTopic.eq("module_id",examinationBatchComSDO.getModileId());//模板id
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		if (topicList.size() <= 0){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains("日常保健")){//如果相等就是安全防护任务
				//模板id
				ids.add(topicList.get(i).getId());
			}
		}
		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
		stuSignUpComDO.setCbatchId(examinationsVo.getCbatchId());
		stuSignUpComDO.setEbatchId(examinationsVo.getEbatchId());
		stuSignUpComDO.setCompetition("B");
		stuSignUpComDO.setJinzhuanTopicId(String.valueOf(ids.get(0)));
		stuSignUpComDO.setCompetitionId(examinationsVo.getCompetitionId());//赛场id
		stuSignUpComDO.setRaceId(examinationBatchComSDO.getId());
		Page<StuSignUpComDO> stuList = stuSignUpService.ListUstASC(examinationsVo.getCurrent(), examinationsVo.getNumber(), stuSignUpComDO);
		if (stuList.getRecords().size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		List<StuSignUpComDO> ss = stuList.getRecords().stream().filter(a -> Objects.nonNull(a.getId())).collect(Collectors.toList());
		stuList.setRecords(ss);
		for (int i = 0 ;i < stuList.getRecords().size(); i++){
			//考生id
			stuIds.add(stuList.getRecords().get(i).getId());
		}
		//查询出打分信息
		Map map =new HashMap();
		map.put("competition","B");
		map.put("signId",stuIds);
		map.put("jinzhuanTopicId",ids);
		map.put("cbatchId",examinationsVo.getCbatchId());
		map.put("ebatchId",examinationsVo.getEbatchId());
		map.put("race_id",examinationBatchComSDO.getId());
		//查询出裁判数量
		List<MarkVO> mrkRefereeVOS = markService.selectRefereeBCSize(map);
		//裁判打分数据
		List<MarkVO> markVOS = markService.seleScoreTopicContent(map);
		if (markVOS.size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//进行学员匹配
		for (int i = 0;i<stuList.getRecords().size();i++){
			ArrayList<MarkVO>	MarkVOlist	=	new ArrayList<>();
			for (int k = 0;k<markVOS.size();k++){
				if (stuList.getRecords().get(i).getId().equals(markVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = markVOS.get(k).getRefereeScore().split("/");//分割出来
					Double refereeScore = 0.0;
					for (String score : refereeScores) {
						refereeScore = Double.valueOf(score) + refereeScore;//两个人分数相加（计算）
					}
					markVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象："+markVOS.get(k));
					MarkVOlist.add(markVOS.get(k));
					stuList.getRecords().get(i).setCbatchId(markVOS.get(k).getCbatchId());
					stuList.getRecords().get(i).setSignId(markVOS.get(k).getSignId());
				}
			}
			//将两个集合合并
			List<MarkVO> resultList = Stream.concat(MarkVOlist.stream(), mrkRefereeVOS.stream())
					.collect(Collectors.toList());
			//去掉重复的裁判数据
			List<MarkVO> resultListDuplicate = resultList.stream().filter(distinctByKey(b->b.getRefereeId())).collect(Collectors.toList());
			if (resultList.size() > 0){
				stuList.getRecords().get(i).setMarkVO(resultListDuplicate);
				stuList.getRecords().get(i).getMarkVO().size();//有多少条数就有多少个裁判
				BigDecimal TotalScore = new BigDecimal(0);
				for (int j = 0; j< stuList.getRecords().get(i).getMarkVO().size();j++){//这个学员的所有裁判打的安全防护分
					if (!stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore().equals("-")){
						TotalScore = new BigDecimal(stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore()).add(TotalScore);//得到所有裁判打的总分
					}
				}
				if (TotalScore.compareTo(BigDecimal.ZERO)!=0){
					BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
					BigDecimal totalScore = TotalScore.divide(size,2,BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);//divide是除以
					//最终学员这个任务所获得的总分
					stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
				}else if (TotalScore.compareTo(BigDecimal.ZERO)==0){
					BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
					BigDecimal totalScore = TotalScore.divide(size);
					stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
				}
			}
		}
		//根据总分进行排序
		Collections.sort(stuList.getRecords(),Comparator.comparing(StuSignUpComDO::getTotalScore).reversed());
		//赛场人数
		statisticsVO.setStuNumber(stuList.getRecords().size());
		//最高分
		Double maxScore = 0.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() > maxScore){
				maxScore = stuList.getRecords().get(i).getTotalScore();
			}
		}
		statisticsVO.setMaxScore(maxScore);
		//最低分
		Double minScore = 100.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() < minScore){
				minScore = stuList.getRecords().get(i).getTotalScore();
			}else if (minScore == 0.0){
				minScore = 0.0;
			}
		}
		statisticsVO.setMinScore(minScore);
		//将用户分数对象存入最终对象里面去
		statisticsVO.setStuSignUpComDO(stuList);
		statisticsVO.setSize(statisticsVO.getStuSignUpComDO().getSize());
		statisticsVO.setTotal(statisticsVO.getStuSignUpComDO().getTotal());
		return Result.ok(statisticsVO);
	}


	/**
	 * 生活照料赛场成绩统计
	 * */
	@ApiOperation(value = "生活照料导赛场成绩统计", notes = "生活照料导赛场成绩统计")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/lookAfterList")
	@ResponseBody
	public Result<?>  lookAfterList(@RequestBody ExaminationsVo examinationsVo){
		StatisticsVO statisticsVO = new StatisticsVO();
		ArrayList<Long>	ids	=	new ArrayList<>();
		ArrayList<Long>	stuIds	=	new ArrayList<>();
		//查询出实操赛场学员信息
		//赛场数据
		ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(examinationsVo.getCompetitionId());
		if (examinationBatchComSDO == null){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//查询模板任务
		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type","C");//赛场（B）
		wrapperTopic.eq("module_id",examinationBatchComSDO.getModileId());//模板id
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		if (topicList.size() <= 0){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains("生活照料")){//如果相等就是安全防护任务
				//模板id
				ids.add(topicList.get(i).getId());
			}
		}
		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
		stuSignUpComDO.setCbatchId(examinationsVo.getCbatchId());
		stuSignUpComDO.setEbatchId(examinationsVo.getEbatchId());
		stuSignUpComDO.setCompetition("C");
		stuSignUpComDO.setJinzhuanTopicId(String.valueOf(ids.get(0)));
		stuSignUpComDO.setCompetitionId(examinationsVo.getCompetitionId());//赛场id
		stuSignUpComDO.setRaceId(examinationBatchComSDO.getId());
		Page<StuSignUpComDO> stuList = stuSignUpService.ListUstASC(examinationsVo.getCurrent(), examinationsVo.getNumber(), stuSignUpComDO);
		List<StuSignUpComDO> ss = stuList.getRecords().stream().filter(a -> Objects.nonNull(a.getId())).collect(Collectors.toList());
		stuList.setRecords(ss);
		if (stuList.getRecords().size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0 ;i < stuList.getRecords().size(); i++){
			//考生id
			stuIds.add(stuList.getRecords().get(i).getId());
		}
		//查询出打分信息
		Map map =new HashMap();
		map.put("competition","C");
		map.put("signId",stuIds);
		map.put("jinzhuanTopicId",ids);
		map.put("cbatchId",examinationsVo.getCbatchId());
		map.put("ebatchId",examinationsVo.getEbatchId());
		map.put("race_id",examinationBatchComSDO.getId());
		//查询出裁判数量
		List<MarkVO> mrkRefereeVOS = markService.selectRefereeBCSize(map);
		//裁判打分数据
		List<MarkVO> markVOS = markService.seleScoreTopicContent(map);
		if (markVOS.size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//进行学员匹配
		for (int i = 0;i<stuList.getRecords().size();i++){
			ArrayList<MarkVO>	MarkVOlist	=	new ArrayList<>();
			for (int k = 0;k<markVOS.size();k++){
				if (stuList.getRecords().get(i).getId().equals(markVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = markVOS.get(k).getRefereeScore().split("/");//分割出来
					Double refereeScore = 0.0;
					for (String score : refereeScores) {
						refereeScore = Double.valueOf(score) + refereeScore;//两个人分数相加（计算）
					}
					markVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象："+markVOS.get(k));
					MarkVOlist.add(markVOS.get(k));
					stuList.getRecords().get(i).setCbatchId(markVOS.get(k).getCbatchId());
					stuList.getRecords().get(i).setSignId(markVOS.get(k).getSignId());
				}
			}
			//将两个集合合并
			List<MarkVO> resultList = Stream.concat(MarkVOlist.stream(), mrkRefereeVOS.stream())
					.collect(Collectors.toList());
			//去掉重复的裁判数据
			List<MarkVO> resultListDuplicate = resultList.stream().filter(distinctByKey(b->b.getRefereeId())).collect(Collectors.toList());
			if(resultListDuplicate.size() > 0){
				stuList.getRecords().get(i).setMarkVO(resultListDuplicate);
				stuList.getRecords().get(i).getMarkVO().size();//有多少条数就有多少个裁判
				BigDecimal TotalScore = new BigDecimal(0);
				for (int j = 0; j< stuList.getRecords().get(i).getMarkVO().size();j++){//这个学员的所有裁判打的安全防护分
					if (!stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore().equals("-")){
						TotalScore = new BigDecimal(stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore()).add(TotalScore);//得到所有裁判打的总分
					}
				}
				BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
				BigDecimal totalScore = TotalScore.divide(size,2,BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
				//最终学员这个任务所获得的总分
				stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
			}
		}
		//根据总分进行排序
		Collections.sort(stuList.getRecords(),Comparator.comparing(StuSignUpComDO::getTotalScore).reversed());
		//赛场人数
		statisticsVO.setStuNumber(stuList.getRecords().size());
		//最高分
		Double maxScore = 0.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() > maxScore){
				maxScore = stuList.getRecords().get(i).getTotalScore();
			}
		}
		statisticsVO.setMaxScore(maxScore);
		//最低分
		Double minScore = 100.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() < minScore){
				minScore = stuList.getRecords().get(i).getTotalScore();
			}else if (minScore == 0.0){
				minScore = 0.0;
			}
		}
		statisticsVO.setMinScore(minScore);
		//将用户分数对象存入最终对象里面去
		statisticsVO.setStuSignUpComDO(stuList);
		statisticsVO.setSize(statisticsVO.getStuSignUpComDO().getSize());
		statisticsVO.setTotal(statisticsVO.getStuSignUpComDO().getTotal());
		return Result.ok(statisticsVO);
	}





	/**
	 *早期发展指导赛场成绩统计
	 * */
	@ApiOperation(value = "早期发展指导赛场成绩统计", notes = "早期发展指导赛场成绩统计")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/developmentGuidanceList")
	@ResponseBody
	public Result<?>  developmentGuidanceList(@RequestBody ExaminationsVo examinationsVo){
		StatisticsVO statisticsVO = new StatisticsVO();
		ArrayList<Long>	ids	=	new ArrayList<>();
		ArrayList<Long>	stuIds	=	new ArrayList<>();
		//查询出实操赛场学员信息
		//赛场数据
		ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(examinationsVo.getCompetitionId());
		if (examinationBatchComSDO == null){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//查询模板任务
		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type","C");//赛场（B）			//模板id
		wrapperTopic.eq("module_id",examinationBatchComSDO.getModileId());//模板id
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		if (topicList.size() <= 0){
			Page<StuSignUpComDO> stuList = new Page<>();
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains("早期发展指导")){//如果相等就是安全防护任务
				//模板id
				ids.add(topicList.get(i).getId());
			}
		}
		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
		stuSignUpComDO.setCbatchId(examinationsVo.getCbatchId());
		stuSignUpComDO.setEbatchId(examinationsVo.getEbatchId());
		stuSignUpComDO.setCompetition("C");
		stuSignUpComDO.setJinzhuanTopicId(String.valueOf(ids.get(0)));
		stuSignUpComDO.setCompetitionId(examinationsVo.getCompetitionId());//赛场id
		stuSignUpComDO.setRaceId(examinationBatchComSDO.getId());
		Page<StuSignUpComDO> stuList = stuSignUpService.ListUstASC(examinationsVo.getCurrent(), examinationsVo.getNumber(), stuSignUpComDO);
		List<StuSignUpComDO> ss = stuList.getRecords().stream().filter(a -> Objects.nonNull(a.getId())).collect(Collectors.toList());
		stuList.setRecords(ss);
		if (stuList.getRecords().size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		for (int i = 0 ;i < stuList.getRecords().size(); i++){
			//考生id
			stuIds.add(stuList.getRecords().get(i).getId());
		}
		//查询出打分信息
		Map map =new HashMap();
		map.put("competition","C");
		map.put("signId",stuIds);
		map.put("jinzhuanTopicId",ids);
		map.put("cbatchId",examinationsVo.getCbatchId());
		map.put("ebatchId",examinationsVo.getEbatchId());
		map.put("race_id",examinationBatchComSDO.getId());
		//查询出裁判数量
		List<MarkVO> mrkRefereeVOS = markService.selectRefereeBCSize(map);
		//裁判打分数据
		List<MarkVO> markVOS = markService.seleScoreTopicContent(map);
		if(markVOS.size() <= 0){
			statisticsVO.setStuSignUpComDO(stuList);
			return Result.ok(statisticsVO);
		}
		//进行学员匹配
		for (int i = 0;i<stuList.getRecords().size();i++){
			ArrayList<MarkVO>	MarkVOlist	=	new ArrayList<>();
			for (int k = 0;k<markVOS.size();k++){
				if (stuList.getRecords().get(i).getId().equals(markVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = markVOS.get(k).getRefereeScore().split("/");//分割出来
					Double refereeScore = 0.0;
					for (String score : refereeScores) {
						refereeScore = Double.valueOf(score) + refereeScore;//两个人分数相加（计算）
					}
					markVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象："+markVOS.get(k));
					MarkVOlist.add(markVOS.get(k));
					stuList.getRecords().get(i).setCbatchId(markVOS.get(k).getCbatchId());
					stuList.getRecords().get(i).setSignId(markVOS.get(k).getSignId());
				}
			}
			//将两个集合合并
			List<MarkVO> resultList = Stream.concat(MarkVOlist.stream(), mrkRefereeVOS.stream())
					.collect(Collectors.toList());
			//去掉重复的裁判数据
			List<MarkVO> resultListDuplicate = resultList.stream().filter(distinctByKey(b->b.getRefereeId())).collect(Collectors.toList());
			if (resultList.size() > 0){
				stuList.getRecords().get(i).setMarkVO(resultListDuplicate);
				stuList.getRecords().get(i).getMarkVO().size();//有多少条数就有多少个裁判
				BigDecimal TotalScore = new BigDecimal(0);
				for (int j = 0; j< stuList.getRecords().get(i).getMarkVO().size();j++){//这个学员的所有裁判打的安全防护分
					if (!stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore().equals("-")){
						TotalScore = new BigDecimal(stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore()).add(TotalScore);//得到所有裁判打的总分
					}
				}
				BigDecimal size = new BigDecimal(stuList.getRecords().get(i).getMarkVO().size());
				BigDecimal totalScore = TotalScore.divide(size,2,BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
				//最终学员这个任务所获得的总分
				stuList.getRecords().get(i).setTotalScore(totalScore.doubleValue());//最终得分为每个裁判打的总分除以裁判人数
			}
		}
		//根据总分进行排序
		Collections.sort(stuList.getRecords(),Comparator.comparing(StuSignUpComDO::getTotalScore).reversed());
		//赛场人数
		statisticsVO.setStuNumber(stuList.getRecords().size());
		//最高分
		Double maxScore = 0.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() > maxScore){
				maxScore = stuList.getRecords().get(i).getTotalScore();
			}
		}
		statisticsVO.setMaxScore(maxScore);
		//最低分
		Double minScore = 100.0;
		for (int i = 0 ;i < stuList.getRecords().size() ; i++){
			if (stuList.getRecords().get(i).getTotalScore() != null && stuList.getRecords().get(i).getTotalScore() < minScore){
				minScore = stuList.getRecords().get(i).getTotalScore();
			}else if (minScore == 0.0){
				minScore = 0.0;
			}
		}
		statisticsVO.setMinScore(minScore);
		//将用户分数对象存入最终对象里面去
		statisticsVO.setStuSignUpComDO(stuList);
		statisticsVO.setSize(statisticsVO.getStuSignUpComDO().getSize());
		statisticsVO.setTotal(statisticsVO.getStuSignUpComDO().getTotal());
		return Result.ok(statisticsVO);
	}


	/**
	 * 个人统计总成绩导出
	 * */
	@ApiOperation(value = "赛场个人总统计", notes = "赛场个人总统计")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/personageTotalStatisticsList")
	@ResponseBody
	public Result<Page<StuSignUpComDO>> personageTotalStatisticsList(@RequestBody ExaminationsVo examinationsVo){
		Page<StuSignUpComDO> list = stuSignUpService.personageTotalStatisticsList(examinationsVo);


		return Result.ok(list);
	}


	/** 裁判打分处理  */
	private void  dateHandle (Page<StuSignUpComDO> stuList,List<MarkVO> secureMarkVOS,String competition) {
		for (int i = 0; i < stuList.getRecords().size(); i++) {
			ArrayList<MarkVO> MarkVO = new ArrayList<>();
			for (int k = 0; k < secureMarkVOS.size(); k++) {
				if (stuList.getRecords().get(i).getId().equals(secureMarkVOS.get(k).getSignId())) {//用户表学员表与打分表考试id匹配
					//计算裁判打的这个任务的总分
					String[] refereeScores = secureMarkVOS.get(k).getRefereeScore().split("/");//分割出来
					Double refereeScore = 0.0;
					for (String score : refereeScores) {
						refereeScore = Double.valueOf(score) + refereeScore;//两个人分数相加（计算）
					}
					secureMarkVOS.get(k).setRefereeScore(String.valueOf(refereeScore));//将裁判打的这个任务的总分存入这个对象中（这里就是这个裁判打的这个任务的总分）
					//计算出这个学员这个任务中所获得的总分（每个裁判总分除以裁判数）//这里k等于几就是有几个裁判
					//如果相同那么将这条数据添加到用户集合对象中去
					System.out.println("对象：" + secureMarkVOS.get(k));
					MarkVO.add(secureMarkVOS.get(k));
				}
			}
			if (MarkVO.size() > 0){
				stuList.getRecords().get(i).setMarkVO(MarkVO);
				stuList.getRecords().get(i).getMarkVO().size();//有多少条数就有多少个裁判
				Double TotalScore = 0.0;
				for (int j = 0; j < stuList.getRecords().get(i).getMarkVO().size(); j++) {//这个学员的所有裁判打的安全防护分
					TotalScore = Double.valueOf(stuList.getRecords().get(i).getMarkVO().get(j).getRefereeScore()) + TotalScore;//得到所有裁判打的总分（这里因为是个人总统计，所以这里是B赛场这个任务所得的总分）

				}
				//这里传入对应的参数，判断是那个赛场的得分
				if (competition.equals("安全防护")){//获得该学员安全防护的得分
					//最终学员这个任务所获得的总分（这里是B赛场安全防护得分），因为是要最终这个学员三个赛场的总得分所以要加上另外两个赛场的得分
					stuList.getRecords().get(i).setSecureScore(new BigDecimal(TotalScore / stuList.getRecords().get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());//最终得分为每个裁判打的总分除以裁判人数
				}else if(competition.equals("日常保健")){//获得该学员的日常保健的得分
					stuList.getRecords().get(i).setHealthScore(new BigDecimal(TotalScore / stuList.getRecords().get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}else if (competition.equals("生活照料")){
					stuList.getRecords().get(i).setLookAfterScore(new BigDecimal(TotalScore / stuList.getRecords().get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}else if (competition.equals("早期发展指导")){
					stuList.getRecords().get(i).setDevelopmentGuidanceScore(new BigDecimal(TotalScore / stuList.getRecords().get(i).getMarkVO().size()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
				}
			}

		}
	}



//	/**
//	 * 分数统计（列表赛场得分数据）
//	 * competition BC赛场
//	 * ebatchId 考试批次
//	 * cbatchId 认证批次
//	 * @return
//	 */
//	@ResponseBody
//	@GetMapping("/scoreStatistics")
//	public Result<Page<MarkDO>> scoreStatistics(String current, String number,String competition,String ebatchId,String cbatchId){//String competition,String ebatchId,String cbatchId,String current, String number
//
//		Map map =new HashMap();
//
//		map.put("competition",competition); //根据赛场查询 abc必填
//
//		if (StringUtil.notEmpty(ebatchId)) { //如果考试批次不为空
//			map.put("ebatchId", ebatchId);
//		}
//
//		// 查询列表数据
//		Page<MarkDO> page = markService.selectListPageMarkDO(Integer.valueOf(current),Integer.valueOf(number),map);
//		List<MarkDO> records = page.getRecords();
//
//		for (int i=0;i<records.size();i++){
//			ExaminationBatchComSDO examinationBatchComSDO = examinationBatchComSService.selectById(records.get(i).getRaceId());
//			records.get(i).setRaceName(examinationBatchComSDO.getName());
//			if (records.get(i).getRealityUm2() == null){
//				records.get(i).setRealityUm2("未参加考试");
//			}
//			List<List<MarkVO>> retMarkVO = new ArrayList<>(); //里面有三个裁判打的五个分数(现在可能是多个裁判)
//			Map selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",records.get(i).getEbatchId()); //考试批次
//			selRefereeIdMap.put("competition",records.get(i).getCompetition()); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeId = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSun = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			Double totalScore = Double.valueOf(scoreSun);
//			totalScore =  (totalScore/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			totalScore = new BigDecimal(totalScore).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			for (int j=0;j<refereeId.size();j++){
//				Map selMarkVo =new HashMap();
//				selMarkVo.put("ebatchId",records.get(i).getEbatchId()); //考试批次
//				selMarkVo.put("competition",records.get(i).getCompetition()); //赛场
//				selMarkVo.put("stuId",records.get(i).getSignId());//考生id
//				selMarkVo.put("refereeId",refereeId.get(j));//裁判id
//				List<MarkVO> markVOS = markService.selectListMarkVO(selMarkVo); //查询出第一个裁判打的五个分数
//				retMarkVO.add(markVOS);
//			}
//			records.get(i).setTotalScore(Double.valueOf(totalScore));
//			records.get(i).setMarkVOs(retMarkVO);
//		}
//		page.setRecords(records);
//		return Result.ok(page);
//	}





	/**
	 * 编辑分数回显（列表修改打分时是数据回显）
	 * competition ABC赛场
	 * ebatchId 考试批次
	 * cbatchId 认证批次
	 * @return
	 */
	@ResponseBody
	@GetMapping("/selEditData")
	public Result<?> selEditData(String competition,String cbatchId,String ebatchId,String signId,String competitionName){//(String competition,String ebatchId,String cbatchId,String stuId
		ArrayList<MarkDO> mrk = new ArrayList<>();
		ArrayList<Long> ids	=	new ArrayList<>();
		MrkRefereeVO mrkRefereeVO = new MrkRefereeVO();
		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
		wrapperTopic.eq("type",competition);//赛场（B）			//模板id
		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
		for (int i = 0;i<topicList.size();i++){
			if (topicList.get(i).getTopicName().contains(competitionName)){//如果相等就是安全防护任务
				//模板id
				ids.add(topicList.get(i).getId());
			}
		}
		//先查询到这个用户有几个裁判打分
		Map map =new HashMap();
		map.put("competition",competition);
		map.put("signId",signId);
		if (cbatchId != null && cbatchId != ""){
			map.put("cbatchId",Long.valueOf(cbatchId));
		}
		if (ebatchId != null && ebatchId != ""){
			map.put("ebatchId",Long.valueOf(ebatchId));
		}
		map.put("jinzhuanTopicId",ids);
		List<MrkRefereeVO> mrkReferee = markService.selectReferee(map);
		//循环查询出裁判打的分数
		Map markMap =new HashMap();
		markMap.put("competition",competition);
		if (cbatchId != null && cbatchId != ""){
			markMap.put(" ",Long.valueOf(cbatchId));
		}
		markMap.put("signId",Long.valueOf(signId));
		for (int i = 0; i < mrkReferee.size(); i++){
			markMap.put("refereeId",mrkReferee.get(i).getRefereeId());
			//某个裁判的打分
			List<MarkVO> markVOS = markService.selectMark(markMap);
			//因为打的不是细则的分了，因此返回的数据中没有细则的具体的数据了这里就需要重新查询出对应的细则数据
			mrkReferee.get(i).setVideo(markVOS.get(0).getVideo());//视频
			mrkReferee.get(i).setPicture(markVOS.get(0).getPicture());//图片
			mrkReferee.get(i).setRefereeRemark(markVOS.get(0).getRefereeRemark());//裁判备注
			mrkReferee.get(i).setRefereeScore(String.valueOf(markVOS.get(0).getUpdateScore()));
			//查询出具体的细则描述等数据
			mrkReferee.get(i).setMarkVO(markVOS);
			mrkReferee.get(i).setMarkStatus(0);//0是已经打过分
		}
		/** 接口更改 */
		return Result.ok(mrkReferee);
	}









	/**
	 * 分数统计 最高分 最低分 总人数（列表最上面，最高分，最低分，赛场总人数）
	 * competition BC赛场
	 * ebatchId 考试批次
	 * cbatchId 认证批次
	 * @return
	 */
	@ResponseBody
	@GetMapping("/getMinMaxStatistics")
	public Result<Map> getMinMaxStatistics(String competition,String ebatchId,String cbatchId){

		Map map =new HashMap();

		map.put("competition",competition); //根据赛场查询 abc必填

		if (StringUtil.notEmpty(ebatchId)) { //如果考试批次不为空
			map.put("ebatchId", ebatchId);
		}
		List<MarkDO> list = markService.selectListMarkDO(map);//查询出对应赛场的考生信息
		Map rstMap =new HashMap();

		if (list.size() >0 ){//如果数据大于0（这个赛场已经有人打过分了）
			Map selRefereeIdMap =new HashMap();
			selRefereeIdMap.put("ebatchId", ebatchId); //考试批次
			selRefereeIdMap.put("competition",competition); //abc赛场
			selRefereeIdMap.put("stuId",list.get(0).getSignId());//考生id
			List<Double> scoreSun = markService.selMaxMinScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
			scoreSun = scoreSun.stream().sorted().collect(Collectors.toList());
			rstMap.put("number",list.size()); //人数
			System.out.println("低0个数据："+scoreSun.get(0));
			//查询出对应的裁判信息（裁判配在了模板任务上面，那么通过模板任务id查询出对应的裁判，模板任务表里面有B或者C做判断）



			double min = (scoreSun.get(0)/3) * 0.7;//除以三就是三个裁判（裁判数据可能是不固定的，这里要变成活动的）
			min = new BigDecimal(min).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
			rstMap.put("min",min); //最低分
			double max = ((scoreSun.get(scoreSun.size()-1)/3) * 0.7);
			max = new BigDecimal(max).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
			rstMap.put("max",max);//最高分
		}else {
			rstMap.put("number",0); //人数
			rstMap.put("min",0); //最低分
			rstMap.put("max",0); //最高分
		}
		return Result.ok(rstMap);
	}


//
//
//	/**
//	 * 个人总统计（个人A赛场，B赛车，C赛场得分及最终个人总得分）
//	 * @return
//	 */
//	@ResponseBody
//	@GetMapping("/sumupStatistics")
//	public Result<Page<MarkStatisticsVO>> sumupStatistics(String ebatchId,String cbatchId,String current,String number){
//
//		//序号 = 每页条数 * （当前点击页码值-1）+ 1
//		Integer xh = Integer.valueOf(number) * ( Integer.valueOf(current) -1 ) + 1;
//
//		Map map =new HashMap();
//		map.put("ebatchId", ebatchId);
//		map.put("cbatchId", cbatchId);
//
//		// 查询列表数据
//		Page<MarkStatisticsVO> page = markService.selectListPageMarkStatisticsVO(Integer.valueOf(current),Integer.valueOf(number),map);
//		List<MarkStatisticsVO> records = page.getRecords();
//
//		for (int i=0;i<records.size();i++){
//			Map selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","0"); //实操
//			List<String> refereeIdA = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunA = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunA == null){
//				scoreSunA = "0";
//			}
//			Double totalScoreA = Double.valueOf(scoreSunA);
//			int type = selCompetitionTypeByEbatchId(ebatchId);
//			if (type == 1){ //如果是教师赛
//				totalScoreA =  (totalScoreA/3) * 0.6; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","1"); //机考分数
//			String jkSore = markService.selTotalScore(selRefereeIdMap); //查询出机考成绩
//			if (jkSore == null){
//				jkSore = "0";
//			}
//			Double totalScoreJikao = Double.valueOf(jkSore);
//			if (type == 1){ //如果是教师赛
//				totalScoreJikao =  totalScoreJikao * 0.4; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreJikao)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreJikao = new BigDecimal(totalScoreJikao).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			totalScoreA = Double.valueOf(String.valueOf((totalScoreA + totalScoreJikao)*0.3));
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","B"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdB = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunB = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunB == null){
//				scoreSunB = "0.0";
//			}
//			Double totalScoreB = Double.valueOf(scoreSunB);
//			totalScoreB =  (totalScoreB/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreB)){
//				totalScoreB = 0.0;
//			}
//			totalScoreB = new BigDecimal(totalScoreB).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","C"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdC = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunC = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunC == null){
//				scoreSunC = "0.0";
//			}
//			Double totalScoreC = Double.valueOf(scoreSunC);
//			totalScoreC =  (totalScoreC/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreC)){
//				totalScoreC = 0.0;
//			}
//			totalScoreC = new BigDecimal(totalScoreC).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			records.get(i).setScoreA(totalScoreA);
//			records.get(i).setScoreB(totalScoreB);
//			records.get(i).setScoreC(totalScoreC);
//			Double zf = totalScoreA + totalScoreB +totalScoreC;
//			zf = new BigDecimal(zf).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			records.get(i).setScoreSum(zf);
//		}
//		for (MarkStatisticsVO markStatisticsVO:records){ //排名
//			markStatisticsVO.setId(xh);
//			xh = xh +1;
//		}
//		page.setRecords(records);
//		return Result.ok(page);
//	}







	private int selCompetitionTypeByEbatchId(String ebatchId){
		ExaminationBatchComDO examinationBatchComDO = examinationBatchComService.selectById(ebatchId);
		if (examinationBatchComDO == null){
			return 0;
		}
		return Integer.valueOf(examinationBatchComDO.getCompetitionType());
	}








//	/**
//	 * 分数统计 最高分 最低分 总人数
//	 * competition ABC赛场
//	 * ebatchId 考试批次
//	 * cbatchId 认证批次
//	 * @return
//	 */
//	@ResponseBody
//	@GetMapping("/getMinMaxSumupStatistics")
//	public Result<Map> getMinMaxSumupStatistics(String ebatchId,String cbatchId){
//		Map map =new HashMap();
//		map.put("ebatchId", ebatchId);
//		map.put("cbatchId", cbatchId);
//		// 查询列表数据
//		List<MarkStatisticsVO> records = markService.selectListMarkStatisticsVO(map);
//
//		for (int i=0;i<records.size();i++){
//			Map selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","0"); //实操
//			List<String> refereeIdA = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunA = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunA == null){
//				scoreSunA = "0";
//			}
//			Double totalScoreA = Double.valueOf(scoreSunA);
//			int type = selCompetitionTypeByEbatchId(ebatchId);
//			if (type == 1){ //如果是教师赛
//				totalScoreA =  (totalScoreA/3) * 0.6; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","1"); //机考分数
//			String jkSore = markService.selTotalScore(selRefereeIdMap); //查询出机考成绩
//			if (jkSore == null){
//				jkSore = "0";
//			}
//			Double totalScoreJikao = Double.valueOf(jkSore);
//			if (type == 1){ //如果是教师赛
//				totalScoreJikao =  totalScoreJikao * 0.4; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreJikao)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreJikao = new BigDecimal(totalScoreJikao).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			totalScoreA = Double.valueOf(String.valueOf((totalScoreA + totalScoreJikao)*0.3));
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","B"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdB = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunB = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunB == null){
//				scoreSunB = "0.0";
//			}
//			Double totalScoreB = Double.valueOf(scoreSunB);
//			totalScoreB =  (totalScoreB/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreB)){
//				totalScoreB = 0.0;
//			}
//			totalScoreB = new BigDecimal(totalScoreB).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","C"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdC = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunC = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunC == null){
//				scoreSunC = "0.0";
//			}
//			Double totalScoreC = Double.valueOf(scoreSunC);
//			totalScoreC =  (totalScoreC/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreC)){
//				totalScoreC = 0.0;
//			}
//			totalScoreC = new BigDecimal(totalScoreC).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			records.get(i).setScoreA(totalScoreA);
//			records.get(i).setScoreB(totalScoreB);
//			records.get(i).setScoreC(totalScoreC);
//			Double zf = totalScoreA + totalScoreB +totalScoreC;
//			zf = new BigDecimal(zf).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			records.get(i).setScoreSum(zf);
//		}
//		Map rstMap =new HashMap();
//		if (records.size() >0 ){
//			rstMap.put("number",records.size()); //人数
//			rstMap.put("max",records.get(0).getScoreSum()); //最低分
//			rstMap.put("min",records.get(records.size()-1).getScoreSum()); //最高分
//		}else {
//			rstMap.put("number",0); //人数
//			rstMap.put("min",0); //最低分
//			rstMap.put("max",0); //最高分
//		}
//		return Result.ok(rstMap);
//	}
//

//
//
//	/**
//	 * 个人总统计导出
//	 * @return
//	 */
//	@ResponseBody
//	@GetMapping("/sumupStatisticsExcel")
//	public void sumupStatisticsExcel(String ebatchId,String cbatchId,HttpServletResponse response){
//
//		Map map =new HashMap();
//		map.put("ebatchId", ebatchId);
//		map.put("cbatchId", cbatchId);
//
//		// 查询列表数据
//		List<MarkStatisticsVO> records = markService.selectListMarkStatisticsVO(map);
//		List<MarkStatisticsExcel> excelList =new ArrayList<>();
//		for (int i=0;i<records.size();i++){
//
//
//			Map selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","0"); //实操
//			List<String> refereeIdA = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunA = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunA == null){
//				scoreSunA = "0";
//			}
//			Double totalScoreA = Double.valueOf(scoreSunA);
//			int type = selCompetitionTypeByEbatchId(ebatchId);
//			if (type == 1){ //如果是教师赛
//				totalScoreA =  (totalScoreA/3) * 0.6; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",cbatchId); //考试批次
//			selRefereeIdMap.put("competition","A"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//			selRefereeIdMap.put("status","1"); //机考分数
//			String jkSore = markService.selTotalScore(selRefereeIdMap); //查询出机考成绩
//			if (jkSore == null){
//				jkSore = "0";
//			}
//			Double totalScoreJikao = Double.valueOf(jkSore);
//			if (type == 1){ //如果是教师赛
//				totalScoreJikao =  totalScoreJikao * 0.4; //题目分数总和 / 裁判数量 * 0.6
//			}
//			if(Double.isNaN(totalScoreJikao)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreJikao = new BigDecimal(totalScoreJikao).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			totalScoreA = Double.valueOf(String.valueOf((totalScoreA + totalScoreJikao)*0.3));
//			if(Double.isNaN(totalScoreA)){ //防止两个过小的数值计算时出现NaN
//				totalScoreA = 0.0;
//			}
//			totalScoreA = new BigDecimal(totalScoreA).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","B"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdB = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunB = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunB == null){
//				scoreSunB = "0.0";
//			}
//			Double totalScoreB = Double.valueOf(scoreSunB);
//			totalScoreB =  (totalScoreB/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreB)){
//				totalScoreB = 0.0;
//			}
//			totalScoreB = new BigDecimal(totalScoreB).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//
//			selRefereeIdMap =new HashMap();
//			selRefereeIdMap.put("ebatchId",ebatchId); //考试批次
//			selRefereeIdMap.put("competition","C"); //abc赛场
//			selRefereeIdMap.put("stuId",records.get(i).getSignId());//考生id
//
//			List<String> refereeIdC = markService.selectRefereeId(selRefereeIdMap); //查询出打分的三个裁判id
//			String scoreSunC = markService.selTotalScore(selRefereeIdMap); //查询出三个裁判十五次打分的总数
//			if (scoreSunC == null){
//				scoreSunC = "0.0";
//			}
//			Double totalScoreC = Double.valueOf(scoreSunC);
//			totalScoreC =  (totalScoreC/3) * 0.7; //题目分数总和 / 裁判数量 * 0.7
//			if (Double.isNaN(totalScoreC)){
//				totalScoreC = 0.0;
//			}
//			totalScoreC = new BigDecimal(totalScoreC).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//
//			records.get(i).setScoreA(totalScoreA);
//			records.get(i).setScoreB(totalScoreB);
//			records.get(i).setScoreC(totalScoreC);
//			Double zf = totalScoreA + totalScoreB +totalScoreC;
//			zf = new BigDecimal(zf).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();//保留小数点后两位
//			records.get(i).setScoreSum(zf);
//		}
//		for (int j=0;j<records.size();j++){
//			MarkStatisticsExcel markStatisticsExcel =new MarkStatisticsExcel();
//			markStatisticsExcel.setId(j+1); //序号
//			markStatisticsExcel.setOrgName(records.get(j).getOrgName());//参赛单位
//			markStatisticsExcel.setIdentity(records.get(j).getIdentity()); //身份证号
//			markStatisticsExcel.setNumber(records.get(j).getNumber()); //参赛序号
//			markStatisticsExcel.setStuName(records.get(j).getStuName());//考生姓名
//			markStatisticsExcel.setScoreA(records.get(j).getScoreA());//A赛场分数
//			markStatisticsExcel.setScoreB(records.get(j).getScoreB());//B赛场分数
//			markStatisticsExcel.setScoreC(records.get(j).getScoreC());//C赛场分数
//			markStatisticsExcel.setScoreSum(records.get(j).getScoreSum()); //总分
//			excelList.add(markStatisticsExcel);
//		}
//		EasyPoiUtil.exportExcel(excelList,  "个人总统计成绩导出",  "个人总统计成绩导出", MarkStatisticsExcel.class,   "个人总统计成绩导出", response);
//	}



	/**
	 * 裁判打分
	 * competition ABC赛场
	 * ebatchId 考试批次
	 * cbatchId 认证批次
	 * jinzhuanTopicId 金砖大赛实操题目id
	 * refereeId 裁判id
	 * signId 学生id
	 * video 视频
	 * picture 图片
	 * score 分数
	 * @return
	 */
	@ResponseBody
	@PostMapping("/judgeMark")
	public Result<Map> judgeMark(@RequestBody MarkVO  markVO){//String competition,String ebatchId,String cbatchId,String jinzhuanTopicId,String refereeId,String signId,String video,String picture,Double score,String raceId,String refereeRemark
		//实操打分
		if (markVO.getMarkDO() != null && markVO.getMarkDO().size() > 0){
	   List<MarkDO>  list = markVO.getMarkDO();
		for (int i = 0; i < list.size();i++){
		if (list.get(i).getCompetition().equals("null")){
			return Result.fail("赛场不能为空");
		}

		if (!StringUtil.notEmpty(list.get(i).getCompetition())){
			return Result.fail("赛场不能为空");
		}
		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getEbatchId()))){
			return Result.fail("考试批次不能为空");
		}

		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getCbatchId()))){
			return Result.fail("认证批次不能为空");
		}

		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getRefereeId()))){
			return Result.fail("裁判不能为空");
		}

		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getRaceId()))){
			return Result.fail("场次不能为空");
		}

		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getJinzhuanTopicId()))){
			return Result.fail("题目不能为空");
		}

		if (!StringUtil.notEmpty(String.valueOf(list.get(i).getSignId()))){
			return Result.fail("考生不能为空");
		}

		if (String.valueOf(list.get(i).getEbatchId()).equals(String.valueOf(list.get(i).getCbatchId()))){
			return Result.fail("ebatchId 与 cbatchId不能相同！");
		}

		EntityWrapper wrapper =new EntityWrapper();
		wrapper.eq("competition",list.get(i).getCompetition() );//赛场
		wrapper.eq("race_id",list.get(i).getRaceId()); //赛场id
		wrapper.eq("ebatch_id",list.get(i).getEbatchId());//考试批次
		wrapper.eq("sign_id",list.get(i).getSignId()); //考生id
		wrapper.eq("referee_id",list.get(i).getRefereeId());//裁判id
		wrapper.eq("content_id",list.get(i).getContentId());//细则id
		wrapper.eq("jinzhuan_topic_id",list.get(i).getJinzhuanTopicId()); //题目id
		List marklist = markService.selectList(wrapper);
		if (marklist.size()>0){
			return Result.fail("请勿重复打分");
		}
		MarkDO markDO =new MarkDO();
		markDO.setCompetition(list.get(i).getCompetition()); //赛场
		markDO.setEbatchId(Long.valueOf(list.get(i).getEbatchId())); //考试批次id
		markDO.setRaceId(Long.valueOf(list.get(i).getRaceId())); //赛场id
		if (StringUtil.notEmpty(String.valueOf(list.get(i).getCbatchId()))){
			markDO.setCbatchId(Long.valueOf(list.get(i).getCbatchId())); //认证批次id
		}
		markDO.setJinzhuanTopicId(Long.valueOf(list.get(i).getJinzhuanTopicId())); //题目id
		markDO.setRefereeId(Long.valueOf(list.get(i).getRefereeId())); //裁判id
		markDO.setSignId(Long.valueOf(list.get(i).getSignId())); //考生id
		if (StringUtil.notEmpty(list.get(i).getVideo()) && !list.get(i).getVideo().equals("null")){
			markDO.setVideo(list.get(i).getVideo()); //视频
		}
		if (StringUtil.notEmpty(list.get(i).getPicture()) && !list.get(i).getPicture().equals("null")){
			markDO.setPicture(list.get(i).getPicture()); //图片
		}
		markDO.setScore(list.get(i).getScore()); //第一次打分分数
		markDO.setRefereeRemark(list.get(i).getRefereeRemark());
		markDO.setStatus(0); //实操打分状态为0
		markDO.setUpdateScore(list.get(i).getScore()); //最终分数修改后
		markDO.setCreateDate(new Date()); //创建时间
		markDO.setUpdateDate(new Date()); //修改时间
		markDO.setContentId(list.get(i).getContentId());
		markService.insert(markDO);
	}
   }else {
				if (markVO.getCompetition().equals("null")){
					return Result.fail("赛场不能为空");
				}

				if (!StringUtil.notEmpty(markVO.getCompetition())){
					return Result.fail("赛场不能为空");
				}
				if (!StringUtil.notEmpty(String.valueOf(markVO.getEbatchId()))){
					return Result.fail("考试批次不能为空");
				}

				if (!StringUtil.notEmpty(String.valueOf(markVO.getCbatchId()))){
					return Result.fail("认证批次不能为空");
				}

				if (!StringUtil.notEmpty(String.valueOf(markVO.getRefereeId()))){
					return Result.fail("裁判不能为空");
				}

				if (!StringUtil.notEmpty(String.valueOf(markVO.getRaceId()))){
					return Result.fail("场次不能为空");
				}

				if (!StringUtil.notEmpty(String.valueOf(markVO.getJinzhuanTopicId()))){
					return Result.fail("题目不能为空");
				}

				if (!StringUtil.notEmpty(String.valueOf(markVO.getSignId()))){
					return Result.fail("考生不能为空");
				}

				if (String.valueOf(markVO.getEbatchId()).equals(String.valueOf(markVO.getCbatchId()))){
					return Result.fail("ebatchId 与 cbatchId不能相同！");
				}

				EntityWrapper wrapper =new EntityWrapper();
				wrapper.eq("race_id",markVO.getRaceId()); //赛场
				wrapper.eq("ebatch_id",markVO.getEbatchId());//考试批次
				wrapper.eq("sign_id",markVO.getSignId()); //考生id
				wrapper.eq("referee_id",markVO.getRefereeId());//裁判id
				List marklist = markService.selectList(wrapper);
				if (marklist.size()>0){
					return Result.fail("请勿重复打分");
				}
				MarkDO markDO =new MarkDO();
				markDO.setCompetition(markVO.getCompetition()); //赛场
				markDO.setEbatchId(Long.valueOf(markVO.getEbatchId())); //考试批次id
				markDO.setRaceId(Long.valueOf(markVO.getRaceId())); //赛场id
				if (StringUtil.notEmpty(String.valueOf(markVO.getCbatchId()))){
					markDO.setCbatchId(Long.valueOf(markVO.getCbatchId())); //认证批次id
				}
				markDO.setRefereeId(Long.valueOf(markVO.getRefereeId())); //裁判id
				markDO.setSignId(Long.valueOf(markVO.getSignId())); //考生id
				if (StringUtil.notEmpty(markVO.getVideo()) && !markVO.getVideo().equals("null")){
					markDO.setVideo(markVO.getVideo()); //视频
				}
				if (StringUtil.notEmpty(markVO.getPicture()) && !markVO.getPicture().equals("null")){
					markDO.setPicture(markVO.getPicture()); //图片
				}
				markDO.setScore(Double.valueOf(markVO.getUpdateScore())); //第一次打分分数
				markDO.setRefereeRemark(markVO.getRefereeRemark());
				markDO.setStatus(0); //实操打分状态为0
				markDO.setUpdateScore(Double.valueOf(markVO.getUpdateScore())); //最终分数修改后
				markDO.setCreateDate(new Date()); //创建时间
				markDO.setUpdateDate(new Date()); //修改时间
				markService.insert(markDO);
		}
		return Result.ok();
	}


	/**
	 * 查询考生备注（对应裁判给考生的备注）
	 * */
	@ResponseBody
	@PostMapping("/examineeRemark")
	public  Result examineeRemark(Long refereeId,Long ebatchId,Long signId,Long  raceId){
			MarkDO markDO = new MarkDO();
			markDO.setRaceId(raceId);//赛场id
			markDO.setEbatchId(ebatchId);//考试批次
			markDO.setSignId(signId);//用户id
			markDO.setRefereeId(refereeId);//裁判id
			MarkDO markDO1 = markService.selectOne(markDO);
			return Result.ok(markDO1);
	}



	/**
	 * 管理员改分
	 */
	@ResponseBody
	@PostMapping("/conservatorJudgeMark")
	public Result<Object> conservatorJudgeMark(@RequestBody MarkVO  markVO){//String id,Double score,String video,String picture,String  refereeRemark

		if (markVO.getMarkDO() != null && markVO.getMarkDO().size() > 0) {
			List<MarkDO> list = markVO.getMarkDO();
			for (int i = 0; i < list.size(); i++) {
				if (list.get(i).getUpdateScore() != null && !list.get(i).getUpdateScore().equals("")) {
					System.out.println("分数：" + list.get(i).getUpdateScore());
					EntityWrapper wrapper = new EntityWrapper();
					wrapper.eq("sign_id", list.get(i).getSignId());
					wrapper.eq("referee_id", list.get(i).getRefereeId());
					wrapper.eq("race_id", list.get(i).getRaceId());
					wrapper.eq("cbatch_id",list.get(i).getCbatchId());
					if (Objects.nonNull(list.get(i).getJinzhuanTopicId())){
						wrapper.eq("jinzhuan_topic_id",list.get(i).getJinzhuanTopicId());
					}
					if (Objects.nonNull(list.get(i).getEbatchId())){
						wrapper.eq("ebatch_id",list.get(i).getEbatchId());
					}
//					wrapper.eq("ebatch_id",list.get(i).getEbatchId());
//					wrapper.eq("content_id", list.get(i).getContentId());
					MarkDO markDO = markService.selectOne(wrapper);
					markDO.setUpdateScore(list.get(i).getUpdateScore());
					markDO.setRefereeRemark(list.get(i).getRefereeRemark());
					if (StringUtil.notEmpty(list.get(i).getVideo()) && !list.get(i).getVideo().equals("null")) {//视频
						markDO.setVideo(list.get(i).getVideo());
					}
					if (StringUtil.notEmpty(list.get(i).getPicture()) && !list.get(i).getPicture().equals("null")) {//图片
						markDO.setPicture(list.get(i).getPicture());
					}
					markService.updateById(markDO);
				}
			}
		}else {
			MarkDO markDO = new MarkDO();
			markDO.setId(markVO.getId());
			markDO.setUpdateScore(Double.valueOf(markVO.getUpdateScore()));
			if (StringUtil.notEmpty(markVO.getVideo()) && !markVO.getVideo().equals("null")) {//视频
				markDO.setVideo(markVO.getVideo());
			}
			if (StringUtil.notEmpty(markVO.getPicture()) && !markVO.getPicture().equals("null")) {//图片
				markDO.setPicture(markVO.getPicture());
			}
			markDO.setRefereeRemark(markVO.getRefereeRemark());
			markService.updateById(markDO);
		}
		return Result.ok();
	}



	/**
	 * 管理员改分
	 */
	@ResponseBody
	@PostMapping("/conservatorJudgeMarks")
	public Result<Object> conservatorJudgeMarks(@RequestParam(value="ids[]")List<String> ids,@RequestParam(value="scores[]")List<Double> scores){

		List<MarkDO> list = markService.selectBatchIds(ids);

		for (int i=0;i<list.size();i++){
			list.get(i).setUpdateScore(scores.get(i));
		}
		markService.updateBatchById(list);
		return Result.ok();
	}





	/**
	 * 加密列表
	 * */
	@ApiOperation(value = "加密列表", notes = "加密列表")
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/personageTotalStatisticsLists")
	@ResponseBody
	public Result<Page<StuSignUpComDO>> personageTotalStatisticsLists(@RequestBody ExaminationsVo examinationsVo){
		Page<StuSignUpComDO> list = stuSignUpService.personageTotalStatisticsLists(examinationsVo);

		return Result.ok(list);
	}

	/** 解密导出 */
	@ResponseBody
	@GetMapping("/personageStatisticsexcelss")
	public Result<String>  personageStatisticsexcelss(Long cbatchId,HttpServletResponse response){
		List<JiemiStatisticsExcel> excelList = stuSignUpService.personageStatisticsexcelss(cbatchId, response);
		EasyPoiUtil.exportExcel(excelList, "选手解密信息导出",  "选手解密信息导出", JiemiStatisticsExcel.class, "选手解密信息导出", response);
		return Result.ok("导出成功！");
	}






	/** 个人总统计导出 */
//	@ResponseBody
//	@GetMapping("/personageStatisticsexcelss")
//	public  Result  personageStatisticsexcelss(Long cbatchId,Long ebatchId,String competitionType,HttpServletResponse response){//实际上这里的cbatchId就是ebatchId前台传的可能有问题
//		List<PersonageStatisticsExcel>	personageStatisticsExcelList	=	new ArrayList<>();
//		StatisticsVO statisticsVO = new StatisticsVO();
//		//B赛安全防护任务id
//		ArrayList<Long>	secureIds	=	new ArrayList<>();
//		//B赛场日常保健任务id
//		ArrayList<Long> healthIds	=	new ArrayList<>();
//		//C赛场生活照料任务id
//		ArrayList<Long> lookAfterIds	=	new ArrayList<>();
//		//C赛场早期发展指导任务id
//		ArrayList<Long> developmentGuidanceIds	=	new ArrayList<>();
//		//考生id集合
//		ArrayList<Long>	stuIds	=	new ArrayList<>();
//		//查询出实操赛场学员信息
//		StuSignUpComDO stuSignUpComDO = new StuSignUpComDO();
//		stuSignUpComDO.setEbatchId(ebatchId);
//		stuSignUpComDO.setCbatchId(cbatchId);
//		List<StuSignUpComDO> stuList = stuSignUpService.ListUstTotalASCss(stuSignUpComDO);
//		if (stuList.size() <= 0){
//			EasyPoiUtil.exportExcel(personageStatisticsExcelList, "选手解密信息导出",  "选手解密信息导出", PersonageStatisticsExcel.class, "选手解密信息导出", response);
//			return Result.ok("没有可导出的数据");
//		}
//		//BC赛场加密序号
//		for (int i = 0; i < stuList.size();i++){
//			ExaminationBatchComSDO examinationBatchComSDO = new ExaminationBatchComSDO();
//			if(StringUtils.isNotBlank(stuList.get(i).getCourt2())){
//				examinationBatchComSDO.setId( Long.valueOf(stuList.get(i).getCourt2()));
//				ExaminationBatchComSDO examinationBatchCom = examinationBatchComSService.selectById(examinationBatchComSDO);
//				stuList.get(i).setEncryptionUmber(examinationBatchCom.getName());
//			}
//		}
//
//		//查询模板任务（这里应为组别不同，每个组下面都会配置一套模板，因此这里不能直接查询出所有数据在判断，可能会出现一个任务有多个）
//		//先查询该批次下配置的赛场，然后查询赛场下配置的任务模板
//		//先查询该批次下赛场配置的模板（B1-C1    B2-C2）
//		EntityWrapper<ExaminationBatchComSDO> wrapper = new EntityWrapper<>();
//		wrapper.eq("pid",ebatchId);
//		//这里查询出批次下的所有赛场（同一个批次下面的不同赛场配置的模板是一样的）
//		List<ExaminationBatchComSDO> examinationBatchComSDOS = examinationBatchComSService.selectList(wrapper);
//		ArrayList<Long>	topicId	=	new ArrayList<>();
//		for (int i = 0;i < examinationBatchComSDOS.size() ; i++){
//			topicId.add(examinationBatchComSDOS.get(i).getModileId());
//		}
//		EntityWrapper<JzJinzhuanDispositionTopic> wrapperTopic = new EntityWrapper<>();
//		wrapperTopic.in("module_id",topicId);
//		List<JzJinzhuanDispositionTopic> topicList = dispositionTopicService.selectList(wrapperTopic);//B赛场所有模板任务
//		//B赛场安全防护赛场
//		String secureTopicName = "";
//		for (int i = 0;i<topicList.size();i++){
//			if (topicList.get(i).getTopicName().contains("安全防护")){//如果相等就是安全防护任务
//				//模板id
//				secureIds.add(topicList.get(i).getId());
//				secureTopicName = "安全防护";
//			}
//		}
//		//B赛场日常保健赛场
//		String healthTopicName = "";
//		for (int i = 0;i<topicList.size();i++){
//			if (topicList.get(i).getTopicName().contains("日常保健")){//如果相等就是安全防护任务
//				//模板id
//				healthIds.add(topicList.get(i).getId());
//				healthTopicName = "日常保健";
//			}
//		}
//		//C赛场生活照料赛场
//		String lookAfterTopicName = "";
//		for (int i = 0;i<topicList.size();i++){
//			if (topicList.get(i).getTopicName().contains("生活照料")){//如果相等就是安全防护任务
//				//模板id
//				lookAfterIds.add(topicList.get(i).getId());
//				lookAfterTopicName = "生活照料";
//			}
//		}
//		//C赛场早期发展指导
//		String developmentGuidanceTopicName = "";
//		for (int i = 0;i<topicList.size();i++){
//			if (topicList.get(i).getTopicName().contains("早期发展指导")){//如果相等就是安全防护任务
//				//模板id
//				developmentGuidanceIds.add(topicList.get(i).getId());
//				developmentGuidanceTopicName = "早期发展指导";
//			}
//		}
//		//考生id
//		for (int i = 0 ;i < stuList.size(); i++){
//			//考生id
//			stuIds.add(stuList.get(i).getId());
//		}
//		/**  这里查询出来该学员BC赛场安全防护任务的总分  */
//		//查询出打分信息
//		Map map =new HashMap();
//		map.put("competition","B");
//		map.put("signId",stuIds);
//		map.put("ebatchId",ebatchId);
//		map.put("cbatchId",cbatchId);
//		if (secureIds.size() > 0){
//			map.put("jinzhuanTopicId",secureIds);
//		}
//		//B赛场安全防护裁判打分数据
//		List<MarkVO> secureMarkVOS = markService.seleScoreTopicContent(map);
//		//B赛场日常保健裁判打分数据
//		map.put("competition","B");
//		if (healthIds.size() > 0){
//			map.put("jinzhuanTopicId",healthIds);
//		}
//		List<MarkVO> healthMarkVOS = markService.seleScoreTopicContent(map);
//		//C赛场生活照料裁判打分数
//		map.put("competition","C");
//		if (lookAfterIds.size() > 0){
//			map.put("jinzhuanTopicId",lookAfterIds);
//		}
//		List<MarkVO> lookAfterMarkVOS = markService.seleScoreTopicContent(map);
//		//C赛场早期发展裁判打分
//		map.put("competition","C");
//		if (developmentGuidanceIds.size() > 0){
//			map.put("jinzhuanTopicId",developmentGuidanceIds);
//		}
//		List<MarkVO> developmentGuidanceMarkVOS = markService.seleScoreTopicContent(map);
//
//		//处理安全防护任务的分数
//		if(secureMarkVOS.size() > 0){
//			dateHandleExcel(stuList,secureMarkVOS,secureTopicName);
//		}
//		//处理日常保健任务的分数
//		if(healthMarkVOS.size() > 0){
//			dateHandleExcel(stuList,healthMarkVOS,healthTopicName);
//		}
//		//处理生活照料任务的分数
//		if (lookAfterMarkVOS.size() > 0){
//			dateHandleExcel(stuList,lookAfterMarkVOS,lookAfterTopicName);
//		}
//		//处理早期发展任务的分数
//		if (developmentGuidanceMarkVOS.size() > 0){
//			dateHandleExcel(stuList,developmentGuidanceMarkVOS,developmentGuidanceTopicName);
//		}
//
//
//		//BC赛场得分
//		for (int i = 0;i < stuList.size();i++){
//			//B赛场任务的得分拼接
//			stuList.get(i).setCompetitionBScore(stuList.get(i).getSecureScore() + "/" + stuList.get(i).getHealthScore());
//			//C赛场任务得分拼接
//			stuList.get(i).setCompetitionCScore(stuList.get(i).getLookAfterScore() + "/" + stuList.get(i).getDevelopmentGuidanceScore());
//		}
//		/**    end     */
//		/** 这里查询学员A赛场总分 */
//		//A赛场这里因为是理论，上面传入的是实操的批次接口所以这里传入的cbatchId是实操的，这里要做一个转换
//		Map aScoremap =new HashMap();
//		aScoremap.put("competition","A");
//		aScoremap.put("signId",stuIds);
//		map.put("ebatchId",ebatchId);
//		if (cbatchId != null){
//			aScoremap.put("ebatchId",cbatchId);
//		}
//		map.put("status",0);//0代表是案例分析裁判打的分（自动打分，数据库中是每个人一条数据）
//		List<MarkVO> markVOS = markService.selectAScore(aScoremap);
//		//查询出对应学员理论机考的成绩
//		aScoremap.put("status",1);//1代表是理论考试的机考题（自动打分，数据库中是每个人一条数据）
//		List<MarkVO> markStatusVOS = markService.selectAListStatusScore(aScoremap);
//		//这里和学员id进行比较
//		for (int i = 0;i < stuList.size();i++){
//			//考生id循环比较
////			Double  refereeScores = 0.0;//多个裁判给学员打分之和
//			BigDecimal refereeScores = new BigDecimal( 0);
//			int size = 0;//裁判个数
//			for (int k = 0; k < markVOS.size();k++){
//				if (stuList.get(i).getId().equals(markVOS.get(k).getSignId())){//如果学员id相同，循环一次就是一个裁判打的分
//					//计算学员A赛
//					refereeScores = new BigDecimal(markVOS.get(k).getUpdateScore()).add(refereeScores);//得到所有裁判打的总分
////					refereeScores = markVOS.get(k).getUpdateScore() + refereeScores;//多个裁判打分相加
//					size = size + 1;//这里每进来一次就加一，裁判数就多一个
//				}
//			}
//			//循环比较完成说明该学员所有裁判打的分都拿出来了
//			//将学员A赛场得分存入
//			if (size > 0) {
//				BigDecimal refeereSize = new BigDecimal(size);
//				BigDecimal scores = refereeScores.divide(refeereSize,2,BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
//				stuList.get(i).setCompetitionAScore(scores.doubleValue());
//			}
//
//			//最终学员得到个人总分（等于A赛场总分加上B赛场总分加上C赛场总分）
//			//A赛场得的总分
////			Double AScore = stuList.get(i).getCompetitionAScore() ;
////			//B赛场得的总分
////			Double BScore =  stuList.get(i).getSecureScore() + stuList.get(i).getHealthScore();
////			//C赛场得到的总分
////			Double CScore = stuList.get(i).getLookAfterScore() + stuList.get(i).getDevelopmentGuidanceScore();
//			Double AScore = 0.0;
//			//循环学员的机考分数
//			Double computerScore = 0.0;
//			for (int j = 0; j < markStatusVOS.size(); j++){
//				//判断学员id是否相等，相等就说明是一个学员的分数
////				for (int l = 0; l < markVOS.size(); l++){
//				if (markStatusVOS.get(j).getSignId().equals(stuList.get(i).getId())){
//					//将分数拿出来
//					computerScore = Double.valueOf(markStatusVOS.get(j).getUpdateScore());
//				}
////				}
//			}
//
//			if (competitionType.equals("1")){//教师组
//				if (stuList.get(i).getCompetitionAScore() != null){//不为空说明有裁判打分是教师组
//					if(computerScore!=0.0){
//						computerScore = computerScore*0.12;
//					}
//					AScore = stuList.get(i).getCompetitionAScore()  +  computerScore;
//					BigDecimal score = new BigDecimal(AScore);
//					BigDecimal scorel =  score.setScale(2,BigDecimal.ROUND_HALF_UP);
//					stuList.get(i).setCompetitionAScore(scorel.doubleValue());
//				}else {//如果教师组裁判打分为空，说明裁判还没有打分，只有机考分
//					AScore = computerScore * 0.12;
//					BigDecimal score = new BigDecimal(AScore);
//					BigDecimal scorel =  score.setScale(2,BigDecimal.ROUND_HALF_UP);
//					stuList.get(i).setCompetitionAScore(scorel.doubleValue());
//				}
//			}else if (competitionType.equals("2") || competitionType.equals("3")){
//				//这里就是学生组的理论分数
//				AScore = computerScore * 0.3;
//				stuList.get(i).setCompetitionAScore(AScore);
//			}
//			//B赛场得的总分
//			Double BScore = 0.0;
//			if (stuList.get(i).getSecureScore() != null && stuList.get(i).getHealthScore() !=  null){
//				BScore =  stuList.get(i).getSecureScore() + stuList.get(i).getHealthScore();
//			}else {
//				stuList.get(i).setSecureScore(0.0);
//				stuList.get(i).setHealthScore(0.0);
//			}
//			//C赛场得到的总分
//			Double CScore = 0.0;
//			if (stuList.get(i).getLookAfterScore() != null && stuList.get(i).getDevelopmentGuidanceScore() != null){
//				CScore = stuList.get(i).getLookAfterScore() + stuList.get(i).getDevelopmentGuidanceScore();
//			}else {
//				stuList.get(i).setLookAfterScore(0.0);
//				stuList.get(i).setDevelopmentGuidanceScore(0.0);
//			}
//
//			//将学员得到的总分存入
//			BigDecimal score = new BigDecimal(((AScore) + (BScore + CScore)));
//			BigDecimal totalScore =  score.setScale(2,BigDecimal.ROUND_HALF_UP);
//			stuList.get(i).setTotalScore(totalScore.doubleValue());
//		}
//		//根据总分进行排序
//		Collections.sort(stuList,Comparator.comparing(StuSignUpComDO::getTotalScore).reversed());
//		/** end */
//		//将用户分数对象存入最终对象里面去
//		for (int i =0;i<stuList.size();i++){
//			PersonageStatisticsExcel personageStatisticsExcel = new PersonageStatisticsExcel();
//			personageStatisticsExcel.setSort(i + 1);
//			personageStatisticsExcel.setComNums(stuList.get(i).getComNums());
//			personageStatisticsExcel.setNum1(String.valueOf(stuList.get(i).getNum1()));
//			personageStatisticsExcel.setNum2(String.valueOf(stuList.get(i).getNum2()));
//			personageStatisticsExcel.setEncryptionUmber(stuList.get(i).getRealityNm1());
//			personageStatisticsExcel.setEncryptionUmber2(stuList.get(i).getRealityNm2());
//			personageStatisticsExcel.setTicketNumber(stuList.get(i).getTicketNumber());
//			personageStatisticsExcel.setUnitName(stuList.get(i).getUnitName());
//			personageStatisticsExcel.setTeacher(stuList.get(i).getTeacher());
//			personageStatisticsExcel.setName(stuList.get(i).getName());
////			personageStatisticsExcel.setIdNumber(stuList.get(i).getIdNumber());
//			personageStatisticsExcel.setTotalScore(stuList.get(i).getTotalScore());
//			personageStatisticsExcel.setCompetitionAScore(stuList.get(i).getCompetitionAScore());
//			personageStatisticsExcel.setSecureScore(stuList.get(i).getSecureScore());
//			personageStatisticsExcel.setHealthScore(stuList.get(i).getHealthScore());
//			personageStatisticsExcel.setLookAfterScore(stuList.get(i).getLookAfterScore());
//			personageStatisticsExcel.setDevelopmentGuidanceScore(stuList.get(i).getDevelopmentGuidanceScore());
////			personageStatisticsExcel.setCompetitionBScore(stuList.get(i).getCompetitionBScore());
////			personageStatisticsExcel.setCompetitionCScore(stuList.get(i).getCompetitionCScore());
//			personageStatisticsExcelList.add(personageStatisticsExcel);
//		}
//		EasyPoiUtil.exportExcel(personageStatisticsExcelList, "选手解密信息导出",  "选手解密信息导出", PersonageStatisticsExcel.class, "选手解密信息导出", response);
//		return Result.ok("导出成功！请勿关闭浏览器,五分钟后浏览！");
//	}


	/** 考生文件导出 */
	@ApiOperation(value = "压缩包下载", notes = "压缩包下载")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@ResponseBody
	@PostMapping(value = "/stuFileDownload")
	public  Result  stuFileDownload(@RequestParam Long cbatchId,HttpServletResponse response){
		return markService.stuFileDownload(cbatchId,response);
	}

}
